package com.fyj.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fyj.service.OrderService;
import common.R;
import entity.order.Orders;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yixin
 * @since 2023-05-12
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /* *
     * @Author: beisheng
     * @Descriprion: 全查
     * @Date: 2023/5/12 17:06
     * @Return: common.R
     * @Param: []
     */

    @GetMapping("/selAllOrder")
    public R selAllOrder(){
        return R.success(orderService.list());
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 根据用户ID查询订单
     * @Date: 2023/5/12 17:06
     * @Return: common.R
     * @Param: [id]
     */

    @GetMapping("/selOrderByUserId")
    public List<Orders> selOrderByUserId(@RequestBody Integer id){
        List<Orders> users = orderService.list(new QueryWrapper<Orders>().eq("user_id", id));
        return users;
    }
}

